/*
 * =====================================================================================
 *
 *       Filename:  main.cpp
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  2017年05月12日 17时39分08秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Crane (), wanghe@galaxyeye-tech.com
 *   Organization:  Galaxy-eye
 *
 * =====================================================================================
 */

void pyramid(int n);
void pyramid_print(int nspace, int level);

//#define  STAR   '*'
#define  STAR   '#'
#define  SPACE  ' '

#include <stdio.h>

int main(int argc, char **argv)
{
    int n = 10;
    pyramid(n);
}

void pyramid(int level)
{
    int nspace = 0;
    int nstar = 2 * level - 1;

    pyramid_print(nspace, nstar);
}

void print_nchar(int n, int  c)
{
    for (int i = 0; i < n; i++)
    {
        putchar(c);
    }
}

void print_star(int nstars)
{
    print_nchar(nstars, STAR);
}

void print_space(int nspace)
{
    print_nchar(nspace, SPACE);
}

void pyramid_print(int nspace, int nstars)
{
    if ( nstars <= 0 )
        return;

    pyramid_print(nspace + 1, nstars - 2);

    print_space(nspace);
    print_star(nstars);
    putchar('\n');
}
